package com.example;

import com.example.service.SendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import java.util.Date;

@SpringBootApplication
@EnableScheduling
public class AmqpProducerApplication implements CommandLineRunner{

	public static void main(String[] args) {
		SpringApplication.run(AmqpProducerApplication.class, args);
	}

	@Autowired
	SendService sendService;

	@Override
	public void run(String... strings) throws Exception {
			//sendService.sendToRabbitmq(UUID.randomUUID().toString());
	}

	@Scheduled(cron = "0 0/1 * * * *")
	public void sendMessage(){
		sendService.sendToRabbitmq(new Date().toString());
	}
}
